package gw.com.android.ui.onlive.analyst;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.gwtsz.gts2.hx.R;

import gw.com.android.utils.PackStatis;

/**
 * @author jett
 * @since 2018-06-05.
 */
public class IntroFragment extends Fragment {

    private CharSequence mIntroduction;
    private TextView tvIntro;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        tvIntro = (TextView) inflater.inflate(R.layout.fragment_analyst_intro, container, false);
        tvIntro.setMovementMethod(ScrollingMovementMethod.getInstance());
        if (!TextUtils.isEmpty(mIntroduction)) {
            tvIntro.setText(mIntroduction);
        }
        return tvIntro;
    }

    public void setIntroduction(String intro) {
        mIntroduction = intro;
        if (tvIntro != null) {
            tvIntro.setText(mIntroduction);
        }
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (getUserVisibleHint()) {
            PackStatis.getToService("clickIntroduction", PackStatis.EventCategory.CIRCLE.getValue(), null, null);
        }
    }
}
